# @shuaige : 陈世玉
# @name :02-爬取星巴克数据.py
# @time :2024/12/5 08:08
import requests
from bs4 import BeautifulSoup
import jsonpath
import json
url='https://www.starbucks.com.cn/assets/search/menu-source-zh.json'
responce=requests.get(url)
data=responce.json()
with open('星巴克数据.json','r',encoding='utf-8') as f:
    data=json.load(f)
    data_list=jsonpath.jsonpath(data,'$..title')
    url_list=jsonpath.jsonpath(data,'$..url')
    body_list=jsonpath.jsonpath(data,'$..body')
    for i in range(len(data_list)):
        url_list[i]="https://www.starbucks.com.cn/assets"+url_list[i]
        print(data_list[i],body_list[i],url_list[i])
